package com.wicket.okrcomponent.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.req.*;
import com.wicket.okrcomponent.biz.service.dto.res.*;
import com.wicket.okrcomponent.common.exception.BizException;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import com.wicket.okrcomponent.common.util.RedisUtil;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.wicket.okrcomponent.base.service.MCustomFields3Service;
import com.wicket.okrcomponent.common.exception.Assert;
import com.wicket.okrcomponent.biz.service.nb.NbTargetContCom;
import com.wicket.okrcomponent.biz.service.ConfSchemeService;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class TargetContComServiceImpl
  implements com.wicket.okrcomponent.biz.service.TargetContComService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  private MCustomFields3Service mCustomFields3Service;
@Resource
  private NbTargetContCom nbTargetContCom;
@Resource
  private ConfSchemeService confSchemeService;
/**
   * D2准备目标内容工作周期初始化配置参数(公共)[9675]
   * gen by moon at 5/29/2024, 11:58:51 PM
   */
  @Trace(operationName = "D2准备目标内容工作周期初始化配置参数(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public PreparationTargetContCycleConfParameterComRespDto preparationTargetContCycleConfParameterCom(PreparationTargetContCycleConfParameterComReqDto reqDto){
    
      
      ImplementTenReceivingFieldRespDto receptionServiceRes_2 =null;
//步骤0: M2执行第十接收字段（特殊方法） - implementTenReceivingField
     //ModelCode: receptionService
        ImplementTenReceivingFieldRespDto receptionServiceRes = null;
    ImplementTenReceivingFieldReqDto receptionServiceReq=new ImplementTenReceivingFieldReqDto();
  if(reqDto!=null){
      receptionServiceReq.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1824994_1
    }
  
    /*M2接收入参字段[8782]  用于特殊方法接收上游入参。 */
    Assert.isNull(receptionServiceReq.getEvaluationTemplateId(),"D2准备目标内容工作周期初始化配置参数(公共)-M2接收入参字段-冗余评价模板ID不能为空",false);
      receptionServiceRes = nbTargetContCom.implementTenReceivingField(receptionServiceReq);
      
      
      
    
//步骤1: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto.setResultAspObjType("EVA_TEMP");//sourceId:1824863_1
queryConfItemMatchAnswerDetailComReqDto.setConfItemCode("CYCLE_MODE");//CUSTOM_CONVENTION//sourceId:1824864_1
queryConfItemMatchAnswerDetailComReqDto.setIsPlatData("FALSE");//sourceId:1824865_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1824862_1
    }
  
    /*D2查评价模板周期模式配置参数答案（公共）[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getResultAspObjId(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板周期模式配置参数答案（公共）-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getResultAspObjType(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板周期模式配置参数答案（公共）-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfItemCode(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板周期模式配置参数答案（公共）-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getIsPlatData(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板周期模式配置参数答案（公共）-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto)/*vcase invoke isSameApp*/;
      
      
      
    
//步骤2: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_2 = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_1=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto_1.setResultAspObjType("EVA_TEMP");//sourceId:1824869_1
queryConfItemMatchAnswerDetailComReqDto_1.setConfItemCode("OPEN_MID_CYCLE");//CUSTOM_CONVENTION//sourceId:1824870_1
queryConfItemMatchAnswerDetailComReqDto_1.setIsPlatData("FALSE");//sourceId:1824871_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto_1.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1824868_1
    }
  
    /*D2查评价模板是否开启中期配置参数答案（公共）[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getResultAspObjId(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板是否开启中期配置参数答案（公共）-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getResultAspObjType(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板是否开启中期配置参数答案（公共）-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getConfItemCode(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板是否开启中期配置参数答案（公共）-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getIsPlatData(),"D2准备目标内容工作周期初始化配置参数(公共)-D2查评价模板是否开启中期配置参数答案（公共）-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto_2 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_1)/*vcase invoke isSameApp*/;
      
      
      
    
//步骤3: M2执行第十接收字段（特殊方法） - implementTenReceivingField
     //ModelCode: receptionService
        ImplementTenReceivingFieldRespDto receptionServiceRes_1 = null;
    if(queryConfItemMatchAnswerDetailComRespDto !=null){
          ImplementTenReceivingFieldReqDto receptionServiceReq_1=new ImplementTenReceivingFieldReqDto();
  if(queryConfItemMatchAnswerDetailComRespDto!=null){
      receptionServiceReq_1.setCycleMode(queryConfItemMatchAnswerDetailComRespDto.getEndValue());//SimpleFieldAssign//sourceId:1825120_1
    }
if(queryConfItemMatchAnswerDetailComRespDto_2!=null){
      receptionServiceReq_1.setOpenMidCycle(queryConfItemMatchAnswerDetailComRespDto_2.getEndValue());//SimpleFieldAssign//sourceId:1825121_1
    }
  
    /*M2接收评价模板配置参数出参[8782]  用于特殊方法接收上游入参。 */
    Assert.isNull(receptionServiceReq_1.getCycleMode(),"D2准备目标内容工作周期初始化配置参数(公共)-M2接收评价模板配置参数出参-周期模式不能为空",false);
      receptionServiceRes_1 = nbTargetContCom.implementTenReceivingField(receptionServiceReq_1);
      
      
      receptionServiceRes_2 = receptionServiceRes_1;
           }
    
PreparationTargetContCycleConfParameterComRespDto retData = new PreparationTargetContCycleConfParameterComRespDto();
  if(receptionServiceRes_2!=null){
      retData.setCycleMode(receptionServiceRes_2.getCycleMode());//SimpleFieldAssign//sourceId:1825123_1
retData.setOpenMidCycle(receptionServiceRes_2.getOpenMidCycle());//SimpleFieldAssign//sourceId:1825124_1
    }
  

  
  
return retData;
  }
  //
}
